import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'
import { ApiProperty } from '@nestjs/swagger'

import { BaseModels, AuthEntity } from './index'

/**
 * @package 账号身份信息
 * @author liu
 */
@Entity({ name: 'role' })
export class RoleEntity extends BaseModels {
  @PrimaryGeneratedColumn()
  id: number

  @Column({ type: 'text' })
  type: string

  @Column({ type: 'int', default: 0 })
  permissions: number

  @OneToMany(type => AuthEntity, user => user.role)
  users: AuthEntity[]
}
